import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function setupAdmin() {
  try {
    // 更新现有用户为admin角色
    const result = await prisma.user.updateMany({
      where: { email: 'admin@test.com' },
      data: { role: 'admin' }
    })
    
    console.log('Updated users:', result.count)
    
    // 查看更新后的用户
    const user = await prisma.user.findUnique({
      where: { email: 'admin@test.com' },
      select: { id: true, loginId: true, email: true, role: true }
    })
    
    console.log('Admin user:', user)
  } catch (error) {
    console.error('Error:', error)
  } finally {
    await prisma.$disconnect()
  }
}

setupAdmin()
